﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Radiation___IM
{
    public class ChannelCommandRunner
    {
        public ChannelCommandRunner()
        {

        }

        public bool ExecuteCommand(string[] command, Client client)
        {
            switch (command[1])
            {
                case "create":
                    if (command.Length >= 3 && command[2].Length > 3)
                    {
                        if (ChannelManager.Instance.add(command[2]) == rvalue.CHANNEL_ALREADY_EXISTS)
                            MessageExecution.sendData(client, "The request channel already exists.");
                        else
                            MessageExecution.sendData(client, "The channel \"" + command[2] + "\" has been created.");
                    }
                    break;
                case "delete":
                    if (command.Length >= 3 && command[2].Length > 3)
                    {
                        if (ChannelManager.Instance.delete(command[2]) == rvalue.CHANNEL_NOT_FOUND)
                            MessageExecution.sendData(client, "The request channel does not exist.");
                        else
                            MessageExecution.sendData(client, "The channel \"" + command[2] + "\" has been deleted.");
                    }
                    break;
                case "help":
                    MessageExecution.sendDataMultiple(client, new string []{ 
                        "-- Channel command --",
                        "  /channel create [name] - Create a channel with the [name] title",
                        "  /channel delete [name] - Delete the channel which has [name] for title",
                        "  /channel motd [name] [message] - NOT IMPLEMENTED",
                        "-- End of this help --"});
                    break;
                default:
                    break;
            }

            return true;
        }
    }
}
